package com.fable.common.enums;

import com.fable.base.ComponentException.ErrCode;
import com.fable.base.EnumCode;

/**
 * 异常枚举类 （该code对应的详细中文信息配置在errorCode.properties文件中）
 */
public enum BusiErrCode implements ErrCode, EnumCode<String> {
    PARAM_ERROR("E-0001", "参数为空"),
    INNER_ERROR("F-0002", "内部异常"),
    SERVER_BUSY("F-0003", "服务器繁忙，请稍后重试！"),
    NO_LOGIN("F-0004", "未登录,请登录！"),
    PRI_CUSTOMER_SUM("F-0005","私海客户不能超过30"),
    ;

    private final String code;

    private final String msg;

    BusiErrCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public String code() {
        return code;
    }

    public String msg() {
        return msg;
    }

    //通过code获取枚举对象
    public static BusiErrCode getBusiErr(String code) {
        for (BusiErrCode errCode : BusiErrCode.values()) {
            if (errCode.code().equals(code)) {
                return errCode;
            }
        }
        return null;
    }
}
